package com.mstore.action;

import java.util.List;
import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.mstore.pojo.Account;
import com.mstore.pojo.AccountAlipayGoods;
import com.mstore.pojo.Tariff;
import com.mstore.service.AccountAlipayGoodsService;
import com.mstore.service.TariffService;

public class AccountAlipayGoodsAction extends BaseAction implements
		SessionAware {

	private static final long serialVersionUID = 2621642809638449772L;

	private AccountAlipayGoodsService accountAlipayGoodsService;

	private List<AccountAlipayGoods> accountAlipayGoods;

	private Map<String, Object> session;

	private String result;

	private TariffService tariffService;

	public String watchAccountAlipayGoods() {
		Object object = session.get("account");
		if (object == null) {
			result = "系统异常，请重新登陆！";
			return "error";
		}
		Account account = (Account) object;

		accountAlipayGoods = accountAlipayGoodsService
				.getAccountAlipayGoodsByEaId(account.getId());
		for (AccountAlipayGoods alipayGoods : accountAlipayGoods) {
			Tariff tariff = tariffService.getTariffByGoodsId(alipayGoods.getGoodId());
			alipayGoods.setTariff(tariff);
		}

		return "watchAccountAlipayGoods";
	}

	public AccountAlipayGoodsService getAccountAlipayGoodsService() {
		return accountAlipayGoodsService;
	}

	public void setAccountAlipayGoodsService(
			AccountAlipayGoodsService accountAlipayGoodsService) {
		this.accountAlipayGoodsService = accountAlipayGoodsService;
	}

	public List<AccountAlipayGoods> getAccountAlipayGoods() {
		return accountAlipayGoods;
	}

	public void setAccountAlipayGoods(
			List<AccountAlipayGoods> accountAlipayGoods) {
		this.accountAlipayGoods = accountAlipayGoods;
	}

	public String getResult() {
		return result;
	}

	public void setResult(String result) {
		this.result = result;
	}

	public TariffService getTariffService() {
		return tariffService;
	}

	public void setTariffService(TariffService tariffService) {
		this.tariffService = tariffService;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

}
